﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="设备资产管理.aspx.cs" Inherits="syc.Jidong.设备资产管理" %>
<html>
<head>
<title></title>
<link href="/TreeView/TreeView.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" language="javascript" src="/TreeView/TreeView.js"></script>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:Label ID="SqlText" runat="server" Visible="False"></asp:Label>
<asp:Label ID="SelectedID" runat="server" Text="" Visible="false"></asp:Label>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
 DeleteCommand="delete from 设备台账 where id=@id;"
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
</DeleteParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
SelectCommand="select ID, cast(id as char(7))+名称 as 名称 FROM 单位编码 where id between 350000 and 359999"
DeleteCommand="if not exists(select ID from 资产编码 where FID=@ID) and not exists(select ID from 设备台账 where 资产编码=@ID) begin delete from 资产编码 where id=@ID end"
>
<DeleteParameters>
<asp:ControlParameter Name="ID" DbType="Int32" Size="4" ControlID="Label_FID"/>
</DeleteParameters>
</asp:SqlDataSource>

<div id="wintop" class="wintop">设备资产管理</div>


<div class="gridframe" style="padding:10px;">
<div class="gridview">
    <table id="mt" border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
        <tr>
            <td class="grid-title" colspan="2" style="padding-left:5px;">
                <div style="float:left; font-weight:normal;">
                    <asp:DropDownList ID="BuMeng" runat="server" DataSourceID="SqlDataSource2" 
                        DataTextField="名称" DataValueField="ID" Width="210px" AutoPostBack="True" Font-Size="13px"
                        onselectedindexchanged="BuMeng_SelectedIndexChanged"></asp:DropDownList>
                    <asp:TextBox ID="Label_FID" runat="server" AutoPostBack="True" ontextchanged="Label_FID_TextChanged" CssClass="hidden" Text="00000000"></asp:TextBox>
                    <asp:CheckBox ID="BaoFei" runat="server" Text="显示报废设备" AutoPostBack="True" 
                        oncheckedchanged="BaoFei_CheckedChanged" />
                </div>
                <div style="float:right">
                    <input type="button" id="Button_New" value="录 入" class="mbutton"/>
                    <asp:Button ID="Button_Edit" runat="server" Text="查看/修改" CssClass="mbutton" UseSubmitBehavior="False"/>   
                    <asp:Button ID="Button_Annex" runat="server" Text="附 件" UseSubmitBehavior="false" CssClass="mbutton" />  
                    <asp:Button ID="Button_Tran" runat="server" Text="转 移" UseSubmitBehavior="false" CssClass="mbutton" />
                    <asp:Button ID="Button_Discard" runat="server" Text="报 废" UseSubmitBehavior="false" CssClass="mbutton" />
                    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="mbutton"  
                        UseSubmitBehavior="False" 
                        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" 
                        onclick="Button_Delete_Click" />
                    <asp:Button ID="Button_TaiZhang" runat="server" Text="设 备 台 账..." UseSubmitBehavior="false" 
                            CssClass="mbutton2" onclick="Button_TaiZhang_Click"/>
                    <asp:Button ID="Button_MingXi" runat="server" Text="固定资产明细..." UseSubmitBehavior="false" 
                            CssClass="mbutton2" onclick="Button_MingXi_Click" />
                    <asp:Button ID="Button_Refresh" runat="server" Text="刷新" onclick="Button_Refresh_Click" UseSubmitBehavior="false" CssClass="hidden"/>
                </div>
            </td>
        </tr>
        <tr>
	        <td class="grid-back" style="background-color:#ffffff;padding-bottom:0px;" width="220">
                <asp:Panel ID="Panel_Tree" runat="server">
                    <div style="height:26px;text-align:right;font-size:14px;color:#6f320a;padding:4px;">
                        <asp:Button ID="Button_Ed" runat="server" Text="=编辑" CssClass="mbutton40" ToolTip="修改当前分类名称" />
                        <asp:Button ID="Button_Del" runat="server" Text="-删除" CssClass="mbutton40" ToolTip="删除当前分类"
                            OnClientClick="if(!confirm('确认要删除当前分类吗？'))return(false);" 
                        onclick="Button_Del_Click" />
                        <asp:Button ID="Button_Add" runat="server" Text="+子类" CssClass="mbutton40" ToolTip="在当前分类下增加子分类" />
                        
                        <asp:Button ID="Button_Mode1" runat="server" Text="高级查询" CssClass="mbutton" 
                            UseSubmitBehavior="False" onclick="Button_Mode1_Click"/>
	                </div>
	                <div id="MyTree" style=" background-color:#ffffff;overflow-x:hidden;overflow-y:scroll;text-align:left;width:220px;"></div>
                </asp:Panel>
                <asp:Panel ID="Panel_Query" runat="server" Visible="false">
	                <div style="height:26px;text-align:right;font-size:14px;color:#6f320a;padding:4px;">
	                    <asp:Button ID="Button_Mode2" runat="server" Text="分类目录" CssClass="mbutton" 
                            UseSubmitBehavior="False" onclick="Button_Mode2_Click"/>
                    </div>
	                <div style="padding:5px;padding-left:10px;background-color:#ffffff;font-size:14px;color:#6f320a;">

                        编　　号：<asp:TextBox ID="BianHao" runat="server" Width="120" CssClass="textbox"></asp:TextBox>
                        <br />名　　称：<asp:TextBox ID="MingCheng" runat="server" Width="120" CssClass="textbox"></asp:TextBox>
                        <br />型　　号：<asp:TextBox ID="XingHao" runat="server" Width="120" CssClass="textbox"></asp:TextBox>
                        <br />厂　　家：<asp:TextBox ID="ChangJia" runat="server" Width="120" CssClass="textbox"></asp:TextBox>
                        <br />投产日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
                        <br />　　至　　<asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

                        <br />
                        <asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
                                    CssClass="mbutton" onclick="Button_Query_Click" />
                            <asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
                                    CssClass="mbutton" onclick="Button_Reset_Click" />
                    </div>
	            </asp:Panel>
	        </td>
            <td class="grid-back">
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                    AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID" 
                    DataSourceID="SqlDataSource1"
                    PageSize="20"
                    GridLines="None" ondatabound="GridView1_DataBound" 
                    onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                    UseAccessibleHeader="False" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged">
                    <PagerSettings Visible="False" />
                    <RowStyle CssClass="grid-row-normal" />
                    <Columns>
                            <asp:TemplateField HeaderText="">
                                <ItemTemplate>
                                    <asp:Button ID="Button_xz" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                    <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="编号" SortExpression="编码">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bh" runat="server" Text='<%# Eval("编码") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="100px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="名称" SortExpression="名称">
                                <ItemTemplate>
                                    <asp:Label ID="Label_mc" runat="server" Text='<%# Eval("名称") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="80px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="型号">
                                <ItemTemplate>
                                    <asp:Label ID="Label_ch" runat="server" Text='<%# Eval("型号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="80px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="厂家" SortExpression="厂家">
                                <ItemTemplate>
                                    <asp:Label ID="Label_cj" runat="server" Text='<%# Eval("厂家") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="80px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="成本(元)" SortExpression="总成本">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zcb" runat="server" Text='<%# Eval("总成本") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="出厂">
                                <ItemTemplate>
                                    <asp:Label ID="Label_cc" runat="server" Text='<%# Eval("出厂日期") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="70px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="投产" SortExpression="投产日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label_tc" runat="server" Text='<%# Eval("投产日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="附件数" SortExpression="附件数">
                                <ItemTemplate>
                                    <asp:Label ID="Label_fj" runat="server" Text='<%# Eval("附件数") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="40px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="状态" SortExpression="状态">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zt" runat="server" Text='<%# Eval("状态描述") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="40px" />
                            </asp:TemplateField>
                    </Columns>
                    <SelectedRowStyle CssClass="grid-row-selected" />
                  </asp:GridView>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <table width="100%">
                    <tr>
                        <td class="pagebar">
                            <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                            <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                            <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            
                            <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                            <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                        </td>
                        <td class="pagebar" align="right">
                            <asp:Label ID="Label_Total" runat="server"></asp:Label>
                        </td>
                    </tr>
               </table>

            </td>
        </tr>
    </table>
    
</div>
</div>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
    var fid = "<%=this.Label_FID.Text %>";
    var sid = "<%=this.SelectedID.Text %>";
    var bmid = "<%=this.BuMeng.Text %>";
</script>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = selectRow;
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }
    
    //var mt = document.getElementById("mt");
    
    
    function TreeView_Save(node) {
    if (typeof (parent.TreeHTML2) != undefined) {
        while (node.className == "nodebox"
            || node.className == "lastsubnode"
            || node.className == "subnode"
            || node.className == "nodeitem") {
            node = node.parentNode;
        }
        parent.TreeHTML2 = node.innerHTML;
    }
}
function TreeView_Restore(TreeView) {
    if (parent.TreeHTML2) {
        if (parent.TreeHTML2 != "") {
            //alert(parent.TreeHTML);
            TreeView.innerHTML = parent.TreeHTML2.replace("class=cnode", "class=anode").replace("contentEditable", "show");
            return true;
        }
    }
    return false;
}
    
   
    function TreeView_SetURL(o,id) {
        o.href = TreeView_Action + id;
        var Label_FID=document.getElementById("Label_FID");
        Label_FID.value=id;
        Label_FID.onchange();
        return false;
    }
    
    var MyTree=document.getElementById("MyTree");
    if (MyTree) {

        TreeView_Href = "/JiDong/资产编码查询.ashx?s=";
        TreeView_Action = "/JiDong/设备资产管理.aspx?fid=";
        TreeView_Create("MyTree", "00000000", "设备资产类别目录", "/Icons/16x16/base.png");

        var ca = document.getElementById(fid).firstChild.lastChild;
        ca.className = "cnode";
        ca.scrollIntoView();

        MyTree.scrollLeft = 0;
        document.getElementById("Button_Ed").onclick = function() {
            parent.swin2_load('/JiDong/资产编码录入.aspx?cmd=ed&id=' + fid, 560, 250);
        };
        document.getElementById("Button_Add").onclick = function() {
            parent.swin2_load('/JiDong/资产编码录入.aspx?cmd=in&id=' + fid, 560, 250);
        };

        window.onresize = function() {
            //var w = document.documentElement.clientWidth;
            //var h = document.documentElement.clientHeight;
            //var w = document.body.clientWidth;
            var h = document.body.clientHeight;
            document.getElementById("MyTree").style.height = (h - 142) + "px";
        }
        window.onresize();
    }

    var Button_New = document.getElementById("Button_New");
    if (Button_New) {
        Button_New.onclick = function() {
            parent.swin2_load("/JiDong/设备登记.aspx?fid=" + fid+"&bmid="+bmid, 820, 350);
        };
    }

    var Button_Edit = document.getElementById("Button_Edit");
    if (Button_Edit) {
        Button_Edit.onclick = function() {
            parent.swin2_load("/JiDong/设备登记.aspx?id=" + sid, 820, 350);
        };
    }

    var Button_Annex = document.getElementById("Button_Annex");
    if (Button_Annex) {
        Button_Annex.onclick = function() {
            parent.swin2_load("/JiDong/设备附件.aspx?id=" + sid, 780, 600, "yes");
        };
    }

    var Button_Tran = document.getElementById("Button_Tran");
    if (Button_Tran) {
        Button_Tran.onclick = function() {
            parent.swin2_load("/JiDong/设备内部转移.aspx?id=" + sid, 770, 232);
        };
    }

    var Button_Discard = document.getElementById("Button_Discard");
    if (Button_Discard) {
        Button_Discard.onclick = function() {
        parent.swin2_load("/JiDong/设备报废申请.aspx?id=" + sid, 800, 360);
        };
    }
</script>
<script>
    <%=this.Autorun %>
</script>
</body>
</html>
